class Reader < ActiveRecord::Base
  has_many :in_records
  has_many :out_records
  has_many :comments
  has_many :orders
  belongs_to :department
  
  
  validates_presence_of :reader_name
  validates_presence_of :password
  validates_presence_of :email
  validates_presence_of :login_name
  
  validates_uniqueness_of :login_name
  validates_uniqueness_of :email
  
  validates_confirmation_of :password,:message => "输入密码不一致"
  
  
  def try_login()
    Reader.find(:first,:conditions => ["login_name = ? and password = ?", self.reader_name , self.password])
  end
  
end
